<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="com.jiadakeji.ppm.modules.sys.utils.*" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>房屋管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
            $("#btnImport").click(function(){
                $.jBox($("#importBox").html(), {title:"导入数据", buttons:{"关闭":true},
                    bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
            });
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
</head>
<body>
<div id="importBox" class="hide">
    <form id="importForm" action="${ctx}/business/room/import" method="post" enctype="multipart/form-data"
          class="form-search" style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入，请稍等...');"><br/>
        <input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>　　
        <input id="btnImportSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
        <a href="${ctx}/business/room/import/template">下载模板</a>
    </form>
</div>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/business/room/">房屋列表</a></li>
		<shiro:hasPermission name="business:room:edit"><li><a href="${ctx}/business/room/form">房屋添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="room" action="${ctx}/business/room/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>小区：</label>
			<form:select path="communityId" class="input-xlarge ">
				<form:option value="" label="请选择"/>
				<form:options items="${fns:getCommunityList()}" itemLabel="name" itemValue="id" htmlEscape="false"/>
			</form:select>
			</li>
			<li><label>楼栋：</label>
				<input type="hidden" name="hidden_buildingId" value="${room.buildingId}"/>
				<form:select path="buildingId" class="input-medium">
					<form:option value="">请选择</form:option>
				</form:select>
			</li>
			<li><label>房屋编号：</label>
				<form:input path="code" htmlEscape="false" maxlength="255" class="input-medium"/>
			</li>
			<li><label>所有者名称：</label>
				<form:input path="houseHolderName" htmlEscape="false" maxlength="32" class="input-medium"/>
			</li>
			<li><label>使用者名称：</label>
				<form:input path="usingCustomerName" htmlEscape="false" maxlength="32" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
                <input id="btnImport" class="btn btn-primary" type="button" value="导入"/>
            </li>

			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr><th>小区</th>
				<th>栋号</th>
				<th>房屋编号</th>
				<th>楼层</th>
				<th>房屋平方单价</th>
				<th>建筑面积</th>
				<th>使用面积</th>
				<th>计费面积</th>
                <th>是否使用</th>
				<th>余额</th>
				<th>所有者</th>
				<th>所有者电话</th>
				<th>使用者</th>
				<th>使用者电话</th>
				<shiro:hasPermission name="business:room:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="room">
			<tr>
				<td>
					${room.building.community.name}
				</td>
				<td>
					${room.building.name}
				</td>
				<td>
					${room.code}
				</td>
				<td>
					${room.storey}
				</td>

				<td>
					${room.roomTypePrice.name}
				</td>

				<td>
					${room.buildAreaSize}
				</td>
				<td>
					${room.usingAreaSize}
				</td>
				<td>
					${room.feeAreaSize}
				</td>
                <td>
                    ${fns:getDictLabel(room.useFlag,"yes_no" ,"" )}
                </td>
				<td>
					${room.balance}
				</td>
				<td>
					${room.houseHolder.name}
				</td>
				<td>
					${room.houseHolder.mobile}
				</td>
				<td>
					${room.usingCustomer.name}
				</td>
				<td>
					${room.usingCustomer.mobile}
				</td>
				<shiro:hasPermission name="business:room:edit"><td>
    				<a href="${ctx}/business/room/form?id=${room.id}">修改</a>
					<a href="${ctx}/business/room/delete?id=${room.id}" onclick="return confirmx('确认要删除该房屋吗？', this.href)">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	<script src="${pageContext.request.contextPath}/static/common/list_relate.js"></script>
	<script>
        jQuery(function($) {
            // 选择联动
            var parameter = {
                url : "/a/business/building/getBuildingList",
                key : "communityId",
                // dataList:"schoolList",
                value : "id",
                text : "name",
                selectedVal : ""
            };
            $("select[name='communityId']").ajaxRelate(
                $("select[name='buildingId']"), parameter);
            $("select[name='buildingId']").val($("input[name='hidden_buildingId']").val()).trigger("change");


        });
	</script>
</body>
</html>